#include <algorithm>
#include <iostream>
#include <string>
using namespace std;

pair<int, int> feet[4] = {{0, 1}, {1, 1}, {0, 0}, {1, 0}};
pair<int, int> dir[4] = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}};
int minx = 0, miny = 0, maxx = 1, maxy = 1;

void Renew() {
  for (int i = 0; i < 4; i++) {
    minx = min(feet[i].first, minx);
    maxx = max(feet[i].first, maxx);
    miny = min(feet[i].second, miny);
    maxy = max(feet[i].second, maxy);
  }
}

void Roate(int o) {
  pair<int, int> O = feet[o];

  for (int i = 0; i < 4; i++) {
    pair<int, int> tmp = feet[i];

    feet[i].first = tmp.second - O.second + O.first;
    feet[i].second = -(tmp.first - O.first) + O.second;
  }
}

bool Check() {
  for (int i = 0; i < 4; i++) {
    for (int j = i + 1; j < 4; j++) {
      if (feet[i] == feet[j]) {
        return true;
      }
    }
  }
  return false;
}

int main() {
  freopen("ballet.in", "r", stdin);
  freopen("ballet.out", "w", stdout);
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n, r = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    string cmd;

    cin >> cmd;

    int p = 0;
    if (cmd[0] == 'R') {
      p += 2;
    }
    if (cmd[1] == 'R') {
      p++;
    }

    int d = -1;
    switch (cmd[2]) {
      case 'F':
        d = 0;
        break;
      case 'B':
        d = 2;
        break;
      case 'L':
        d = 3;
        break;
      case 'R':
        d = 1;
        break;
    }
    if (d == -1) {
      Roate(p);
      r++;
    } else {
      feet[p].first += dir[(d + r) & 3].first;
      feet[p].second += dir[(d + r) & 3].second;
    }
    if (Check()) {
      cout << "-1\n";
      return 0;
    }
    Renew();
  }
  cout << (maxx - minx + 1) * (maxy - miny + 1) << "\n";
  return 0;
}